In [ ]:
breakfast = ["sausage", "eggs", "bacon", "spam"]
Write then a for which loop determines the squares of the odd
integers up to 10. Use the range() function.
In [ ]:
In [ ]:
fruits = {'banana' : 5, 'strawberry' : 7, 'pineapple' : 3}
Next, write a loop that sums up the prices.
In [ ]:
In [ ]:
In [ ]:
In [ ]:
xys = [[2, 3], [0, -1], [4, -2], [1, 6]]
Next, create a new list containing only the sorted y values.
In [ ]:
Then, create a new list consisting of sums of the (x,y) pairs.
In [ ]:
Finally, create a new list consisting of sums the (x,y) pairs where both x and y are positive.
In [ ]:
This is a classic job interview question. Depending on the interviewer or interviewee it can filter out up to 95% of the interviewees for a position. The task is not difficult but it's easy to make simple mistakes.
If a number is divisible by 3, instead of the number print "Fizz", if a number is divisible by 5, print "Buzz" and if the number is divisible by both 3 and 5, print "FizzBuzz".
In [2]:
numbers = range(1, 101)
Food for thought: How do people commonly fail this test and why?
In [ ]:
In [5]:
import random
value = random.random()
value
Out[5]:
In [ ]:
temperatures_celsius = [0, -15, 20.15, 13.3, -5.2]